module GeoHelper
  def distance_km_from_degrees(deg)
    return deg*40041.455/360
  end

  def q_width_for_km(km)
    return km*1.7/16.9
  end

  def q_height_for_km(km)
    return km*1.7/12.6
  end

  def zoom_from_q(q)
    zoom = 13
    zoom = 12 if q >= 1
    zoom = 11 if q >= 2
    zoom = 10 if q >= 3.86
    zoom = 9 if q >= 7.72
    zoom = 8 if q >= 15.45
    zoom = 7 if q >= 31.48
    return zoom
  end
end
